CREATE
OR REPLACE PROCEDURE tbch_insert_tbjdfxpg(p_phid IN NUMBER) 
AS 

BEGIN
    INSERT INTO p_form_tbjdfxpg_m(
        phid,
        phid_org,
        u_basp,
        u_xmmc,
        u_djly,
        bill_no,
        u_bdmc,
        u_ssdw,
        phid_fill_psn,
        bill_dt,
        app_status,
        ng_insert_dt,
        ng_update_dt,
        ng_record_ver,
        wf_flag
    )
    SELECT
        seq_auto_phid_bsps_tbjdfxpg.nextval,
        phid_org,
        '分公司',
        user_xmmc,
        p_phid,
        bill_no,
        user_bdmc,
        phid_org,
        user_tbr,
        TRUNC(SYSDATE),
        0,
        TRUNC(SYSDATE),
        TRUNC(SYSDATE),
        2,
        0
    FROM crm3_tend_chk_m
    WHERE phid = p_phid;
    commit;
    EXCEPTION 
    WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('插入失败，错误信息：' || SQLERRM);
    RAISE;
    ROLLBACK;
END tbch_insert_tbjdfxpg;